package com.pandora.credit.mongo.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;

/**
 * @author developer
 */
@Document(collection = "news")
public class MongoNews {

    @Field("_id")
    @JsonProperty("_id")
    private Long id;
    private MongoNewsItem item;
    @Field("created_time")
    @JsonProperty("created_time")
    private Date createdTime;
    @Field("updated_time")
    @JsonProperty("updated_time")
    private Date updatedTime;

    public MongoNews(){}

    public MongoNews(Long id, MongoNewsItem item, Date createdTime, Date updatedTime) {
        this.id = id;
        this.item = item;
        this.createdTime = createdTime;
        this.updatedTime = updatedTime;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public MongoNewsItem getItem() {
        return item;
    }

    public void setItem(MongoNewsItem item) {
        this.item = item;
    }

    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public Date getUpdatedTime() {
        return updatedTime;
    }

    public void setUpdatedTime(Date updatedTime) {
        this.updatedTime = updatedTime;
    }

    public static class MongoNewsItem{
        @Field("dest_url")
        @JsonProperty("dest_url")
        private String destUrl;
        @Field("img_url")
        @JsonProperty("img_url")
        private String imgUrl;
        private String name;
        private Date date;

        public MongoNewsItem(String destUrl, String imgUrl, String name, Date date) {
            this.destUrl = destUrl;
            this.imgUrl = imgUrl;
            this.name = name;
            this.date = date;
        }

        public String getDestUrl() {
            return destUrl;
        }

        public void setDestUrl(String destUrl) {
            this.destUrl = destUrl;
        }

        public String getImgUrl() {
            return imgUrl;
        }

        public void setImgUrl(String imgUrl) {
            this.imgUrl = imgUrl;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Date getDate() {
            return date;
        }

        public void setDate(Date date) {
            this.date = date;
        }
    }
}
